import React, { Component } from "react";
import { Card, Table } from "antd";
import * as echarts from "echarts";

class HighRiskHostAnalysis extends Component {
  constructor(props) {
    super(props);
    this.state = {};
  }
  options = () => {
    var chartDom = document.getElementsByClassName("main")[0];
    var myChart = echarts.init(chartDom);
    var option;

    option = {
      title: {
        text: "高危主机列表",
      },
      xAxis: {
        name: "域名",
        type: "category",
        data: [
          "192.168.13.1",
          "192.168.17.18",
          "192.168.15.23",
          "192.168.46.22",
          "192.168.13.14",
          "192.168.13.15",
          "192.168.79.23",
        ],
      },
      yAxis: {
        name: "数值",
        type: "value",
      },
      series: [
        {
          data: [120, 200, 150, 80, 70, 110, 130],
          type: "bar",
          barWidth: 60,
        },
      ],
    };

    option && myChart.setOption(option);
  };
  componentDidMount() {
    this.options();
  }
  render() {
    const dataSource = [
      {
        key: "1",
        source: "192.168.13.2",
        trend: "-----",
        alarm: "203",
        new: "2021/07/06",
      },
      {
        key: "2",
        source: "192.168.13.21",
        trend: "-----",
        alarm: "201",
        new: "2021/07/08",
      },
    ];

    const columns = [
      {
        title: "来源",
        dataIndex: "source",
        key: "source",
      },
      {
        title: "结束",
        dataIndex: "trend",
        key: "trend",
      },
      {
        title: "警报",
        dataIndex: "alarm",
        key: "alarm",
      },
      {
        title: "最新的警报",
        dataIndex: "new",
        key: "new",
      },
    ];
    return (
      <div>
        <Card className="main" style={{ width: 1200, height: 400 }}></Card>

        <Card title="高危端点">
          <Table dataSource={dataSource} columns={columns} />
        </Card>
      </div>
    );
  }
}

export default HighRiskHostAnalysis;
